package sbe.sonar.client.database;

import java.io.Serializable;

import javax.persistence.*;

import java.util.List;


/**
 * The persistent class for the Repository database table.
 * 
 */
@Entity
@Table(name="Repository", schema="SVNApplications")
@NamedQuery(name="Repository.findAll", query="SELECT r FROM Repository r")
public class Repository implements Serializable {
	private static final long serialVersionUID = 1L;
	private String idRepository;
	private String svnurl;
	private List<ApplicationsByRepository> applicationsByRepositories;
	private List<Application> applications;

	public Repository() {
	}


	@Id
	public String getIdRepository() {
		return this.idRepository;
	}

	public void setIdRepository(String idRepository) {
		this.idRepository = idRepository;
	}


	public String getSvnurl() {
		return this.svnurl;
	}

	public void setSvnurl(String svnurl) {
		this.svnurl = svnurl;
	}


	//bi-directional many-to-one association to ApplicationsByRepository
	@OneToMany(mappedBy="repository", fetch=FetchType.EAGER)
	public List<ApplicationsByRepository> getApplicationsByRepositories() {
		return this.applicationsByRepositories;
	}

	public void setApplicationsByRepositories(List<ApplicationsByRepository> applicationsByRepositories) {
		this.applicationsByRepositories = applicationsByRepositories;
	}

	public ApplicationsByRepository addApplicationsByRepository(ApplicationsByRepository applicationsByRepository) {
		getApplicationsByRepositories().add(applicationsByRepository);
		applicationsByRepository.setRepository(this);

		return applicationsByRepository;
	}

	public ApplicationsByRepository removeApplicationsByRepository(ApplicationsByRepository applicationsByRepository) {
		getApplicationsByRepositories().remove(applicationsByRepository);
		applicationsByRepository.setRepository(null);

		return applicationsByRepository;
	}


	//bi-directional many-to-many association to Application
	@ManyToMany(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST, CascadeType.REMOVE})
	@JoinTable(
		name="ApplicationsByRepository"
		, joinColumns={
			@JoinColumn(name="idRepository")
			}
		, inverseJoinColumns={
			@JoinColumn(name="idApplication")
			}
		)
	public List<Application> getApplications() {
		return this.applications;
	}

	public void setApplications(List<Application> applications) {
		this.applications = applications;
	}

}